home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / Miracle C Compiler / miricleC compiler.msi / Instal01.cab / _224D4DF27FE541DBB604435A927B9274 < prev    next >
Encoding:
Text File  |  2000-08-04  |  978 b   |  43 lines

  1. #include <time.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <assert.h>
  5.  
  6. void xtime();
  7.  
  8. int main()
  9. {
  10.     xtime();
  11. }
  12.  
  13. void xtime()
  14. {
  15.     time_t t;
  16.     struct tm *pm, m;
  17.  
  18.     printf("==> starting xtime <==\n");
  19.     m.tm_sec=56;    m.tm_min=48;    m.tm_hour=21;
  20.     m.tm_mday=12;    m.tm_mon=9;    m.tm_year=85;
  21.  
  22.     t=mktime(&m);
  23.     assert(m.tm_wday==6); assert(m.tm_yday==284);
  24.  
  25.     assert(t==182468936L);
  26.     assert(difftime(time(NULL),t) > 0.0);    // --- running this after 1985
  27.  
  28.     pm=localtime(&t);
  29.     assert(pm->tm_year==85);    assert(pm->tm_mon==9);    assert(pm->tm_mday==12);
  30.     assert(pm->tm_hour==21);    assert(pm->tm_min==48);    assert(pm->tm_sec==56);
  31.     assert(pm->tm_wday==6);        assert(pm->tm_yday==284);
  32.     assert(strcmp(asctime(pm),"Sat Oct 12 21:48:56 1985\n")==0);
  33.  
  34.     t=time(NULL);    printf("Today is:%sPlease wait.....",ctime(&t));
  35.     sleep(5L);
  36.     t=time(NULL);    printf("\nToday+5s:%s",ctime(&t));
  37.  
  38.     printf("passed time tests...\n");
  39.     printf("==> finished xtime <==\n");
  40.  
  41.     return;
  42. }
  43.